Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

is-svg

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-svg

Check if a string or buffer is SVG

  • 4.4.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.3M
increased by56.76%
Maintainers
1
Weekly downloads
 
Created

What is is-svg?

The is-svg npm package is used to check if a given string or buffer is an SVG (Scalable Vector Graphics) image. It's particularly useful in scenarios where you need to validate input files or data to ensure they are SVGs before processing them further. This can help in avoiding errors or security issues when working with image processing or rendering functionalities.

What are is-svg's main functionalities?

Check if a string is SVG

This feature allows you to check if a string is valid SVG. It's useful when you have SVG data as a string and need to verify its validity before using it.

"const isSvg = require('is-svg');\n\nconst svgString = '<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 100 100\"><circle cx=\"50\" cy=\"50\" r=\"40\"/></svg>';\nconsole.log(isSvg(svgString)); // true"

Check if a Buffer is SVG

This feature enables you to check if a Buffer (for example, read from a file) contains SVG data. It's particularly useful for file validation in upload forms or file processing systems.

"const isSvg = require('is-svg');\nconst fs = require('fs');\n\nconst svgBuffer = fs.readFileSync('image.svg');\nconsole.log(isSvg(svgBuffer)); // true or false based on the file content"

Other packages similar to is-svg

Keywords

FAQs

Package last updated on 28 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc